package org.vnl.platform.web.impl.myfaces.dojo.component.tag;

import javax.el.ValueExpression;

import javax.faces.component.UIComponent;

import org.vnl.platform.web.impl.myfaces.dojo.IDojoConstants;
import org.vnl.platform.web.impl.myfaces.dojo.component.DojoAjaxForm;


public class DojoAjaxFormTag extends DojoFormTag {

    private ValueExpression resultId;

    public ValueExpression getResultId() {
        return resultId;
    }

    public void setResultId(ValueExpression resultId) {
        this.resultId = resultId;
    }

    @Override
    public String getComponentType() {
        return IDojoConstants.COMPONENT_AJAX_FORM_TYPE;
    }

    @Override
    public String getRendererType() {
        return IDojoConstants.COMPONENT_AJAX_FORM_TYPE;
    }

    @Override
    protected void setProperties(UIComponent arg0) {
        super.setProperties(arg0);
        if (arg0 instanceof DojoAjaxForm) {
            if (resultId != null) {
                Object obj = resultId.getValue(getELContext());
                if (obj != null) 
                    ((DojoAjaxForm) arg0).setResultId(obj.toString());
            }
        }
    }
    
}
